//
//  Modelo_Variantes.cpp
//  PEI
//
//  Created by asc on 04/04/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include <iostream>
#include "Modelo_Variantes.h"

/*
 * CODE_VARIANTES
 */
variantes::variantes(int init):variante(init)
{
    setVariante(init);
}


void variantes::setVariante(int i)
{
    live.clear();
    dead.clear();
    switch (i) {
        case 0:
            /*     /3       */
            live.push_back(3);
            nombre="Casi todo es una chispa";
            descripcion = "/3";
            break;
        case 1:
            /* 5678/35678   */
            dead.push_back(5);
            dead.push_back(6);
            dead.push_back(7);
            dead.push_back(8);
            
            live.push_back(3);
            live.push_back(5);
            live.push_back(6);
            live.push_back(7);
            live.push_back(8);
            nombre="Diamantes Catastrofe";
            descripcion = "5678/35678";
            break;
        case 2:
            /* 1357/1357    */
            dead.push_back(1);
            dead.push_back(3);
            dead.push_back(5);
            dead.push_back(7);
            
            live.push_back(1);
            live.push_back(3);
            live.push_back(5);
            live.push_back(7);
            
            nombre = "Todo son Replicantes";
            descripcion = "1357/1357";
            break;
        case 3:
            /* 1358/357     */
            dead.push_back(1);
            dead.push_back(3);
            dead.push_back(5);
            dead.push_back(8);
            
            live.push_back(3);
            live.push_back(5);
            live.push_back(7);
            
            nombre = "Reino equilibrado de Amebas";
            descripcion = "1358/357";
            break;
        case 4:
            /*   23/3       */
            dead.push_back(2);
            dead.push_back(3);
            
            live.push_back(3);
            
            nombre = "Juego de Vida de Conway";
            descripcion = "23/3";
            break;
        case 5:
            /*   23/36      */
            dead.push_back(2);
            dead.push_back(3);
            
            live.push_back(3);
            live.push_back(6);
            
            nombre = "HighLife";
            descripcion = "23/36";
            break;
        case 6:
            /*235678/3678   */
            dead.push_back(2);
            dead.push_back(3);
            dead.push_back(5);
            dead.push_back(6);
            dead.push_back(7);
            dead.push_back(8);
            
            live.push_back(3);
            live.push_back(6);
            live.push_back(7);
            live.push_back(8);
            
            nombre = "Mancha de tinta que se seca rapidamente";
            descripcion = "235678/3678";
            break;
        case 7:
            /*  245/368     */
            dead.push_back(2);
            dead.push_back(4);
            dead.push_back(5);
            
            live.push_back(3);
            live.push_back(6);
            live.push_back(8);
            
            nombre = "Muerte Locomotoras y Naves";
            descripcion = "245/368";
            break;
        case 8:
            /*    34/34     */
            dead.push_back(3);
            dead.push_back(4);
            
            live.push_back(3);
            live.push_back(4);
            
            nombre = "Vida 34";
            descripcion = "34/34";
            break;
        case 9:
            /*   51/346     */
            dead.push_back(5);
            dead.push_back(1);
            
            live.push_back(3);
            live.push_back(4);
            live.push_back(6);
            
            nombre = "Larga Vida casi todo Osciladores";
            descripcion = "51/346";
        default:
            break;
    }  
}

bool variantes::debeMorir(int nVecinos)
{
    bool accion = (find(list<int>::iterator() = dead.begin(), dead.end(), nVecinos) == dead.end());
    //cerr << "Morir?\t" << accion << endl;
    return !accion;
}

bool variantes::debeNacer(int nVecinos)
{
    bool accion = (find(list<int>::iterator() = live.begin(), live.end(), nVecinos) != live.end());
    //cerr << "Nacer?\t" << accion << endl;
    return accion;
}

string variantes::getNombre()
{
    return nombre;
}

string variantes::getDesc()
{
    return descripcion;
}
